package myJs.search.circDetail

import myJs.Implicits._
import myJs.MainCp
import myJs.myPkg.ReactRouterDOM
import org.scalajs.dom.URLSearchParams
import slinky.core.FunctionalComponent
import slinky.core.annotations.react
import slinky.web.html._

/**
 * Created by yz on 21/1/2022
 */
@react object Cp {

  type Props = Unit
  val curPage = CircDetail

  val component = FunctionalComponent[Props] { props =>

    val location = ReactRouterDOM.useLocation()
    val searchParams = new URLSearchParams(location.search)
    val species = searchParams.get("species").null2Empty
    val circId = searchParams.get("circId").null2Empty

    val ele = species match {
      case "Hsa" => HCp(circId = circId)
      case "Mmu" => MCp(circId = circId)
    }
    MainCp(title = curPage.titleStr)(
      div(className := "panel panel-default",
        div(className := "panel-heading",
          h3(className := "panel-title",
            s"${curPage.titleStr} - ${circId}"
          )
        ),
        div(className := "panel-body",
          ele
        )
      )
    )

  }

  object STool {


  }

}
